package com.cby.android.sample.repository

import com.cby.android.sample.repository.api.ApiSource
import com.cby.android.sample.repository.api.CaiYunService
import com.cby.android.sample.bean.caiyun.CaiYunApiResponse
import com.cby.android.sample.bean.caiyun.CaiYunResultBean

/**
 * @description: CaiYunRepository
 * @author: ChenBaoYang
 * @createDate: 2022/5/6 3:02 下午
 */
interface CaiYunApi {

    /**
     * 获取天气信息，从彩云技术API接口
     *
     * @param location String?
     * @return CaiYunApiResponse<CaiYunResultBean>
     */
    suspend fun getWeatherFromCaiyun(location: String?): CaiYunApiResponse<CaiYunResultBean>
}

class CaiYunApiImpl : CaiYunApi {

    private var service: CaiYunService =
        ApiSource.getCaiYunWeatherService(CaiYunService::class.java)

    override suspend fun getWeatherFromCaiyun(location: String?): CaiYunApiResponse<CaiYunResultBean> =
        service.getWeatherFromCaiyun(location)
}